package com.westcom.healthmate.common.network.http;
import java.io.IOException;
import java.net.URI;

import com.westcom.healthmate.common.network.http.Response;
import com.westcom.healthmate.common.utils.CommonUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.impl.client.DefaultHttpClient;

public class SyncDelete 
{
	private DefaultHttpClient mHttpClient;
	
    public static SyncDelete create() {
        return new SyncDelete();
    }
    
    public SyncDelete() {
	    mHttpClient = new DefaultHttpClient();
    }
    public HttpResponse delete(String url,org.apache.http.Header[] h,HttpEntity entity) throws ClientProtocolException, IOException
    {
    	HttpDeleteWithBody httpdelete = new HttpDeleteWithBody(url);
    	if(null != h)
    	{
    		httpdelete.setHeaders(h);
    	}
    	if(null != entity)
    	{
    		httpdelete.setEntity(entity);
    	}
        CommonUtils.disableSSLVerification(mHttpClient);
        HttpResponse httpResponse = mHttpClient.execute(httpdelete);
        return httpResponse;
    }
    
    public class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase
    {
    	public static final String METHOD_NAME = "DELETE";
        public String getMethod() { return METHOD_NAME;}
        public HttpDeleteWithBody(final String uri) 
        {
        	super();
        	setURI(URI.create(uri));
    	}
        public HttpDeleteWithBody(final URI uri)
        {
            super();
            setURI(uri);
        }
        public HttpDeleteWithBody() 
    	{
        	super();
        }
    }
    
}